﻿
using MyFloridaHouse.libSvOpenDistricts.Dialogs;
using MyFloridaHouse.libSvCommonUtilities;
namespace MyFloridaHouse.libSvOpenDistricts.ViewModel
{
    public partial class ViewModelBase
    {
        public DistrictCustomizationDlg districtCustomizationDlg;
    
        private bool CmdPrefDistrictCanExecute(object parameter)
        {
            return (districtPlan.districtCount > 0);
        }

        private void CmdPrefDistrictExecute(object parameter)
        {
            if (districtPlan.districtCount > 0)
            {
                districtCustomizationDlg = new DistrictCustomizationDlg(OnMemberPropertyChanged, DisplayPanelForDialogs);
                districtCustomizationDlg.Start(CmdPrefDistrictGetDistrictCustomizationDone);
                districtCustomizationDlg.targetPopulation = Constants.TOTAL_POPULATION_TO_BE_APPORTIONED / districtPlan.districtCount;
            }
        }

        private void CmdPrefDistrictGetDistrictCustomizationDone(bool result)
        {
            if (result)
            {
                districtPlan.SetDistrictTargetPopulation(districtCustomizationDlg.targetPopulation);
                BuildDistrictSummaryAll();
            }
            districtCustomizationDlg = null;
        }



    }
}
